package ru.st.selenium;

import org.testng.annotations.Test;

import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;

import org.testng.*;
import org.testng.annotations.*;
import org.testng.*;

import static org.hamcrest.CoreMatchers.*;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;

public class DeleteFilmTest extends ru.st.selenium.pages.TestBase {

	@Test
	  public void LoginTest() throws Exception {
		driver.get(baseUrl + "/php4dvd/");
	    
		WebElement usernameField = driver.findElement(By.id("username"));
	    usernameField.clear();
	    usernameField.sendKeys("admin");
	    
	    WebElement passwordField = driver.findElement(By.name("password"));
	    passwordField.clear();
	    passwordField.sendKeys("admin");
	    
	    driver.findElement(By.name("submit")).click();
	   }
	
	@Test
	  public void testDelete() throws Exception {
		  driver.get(baseUrl + "/php4dvd/");
		  
		  driver.findElement(By.xpath("//div[.=\"Film\"]")).click();
		  driver.findElement(By.cssSelector("img[alt=\"Remove\"]")).click();
		  Alert alert = driver.switchTo().alert();
		  alert.accept();
		  //assertTrue(closeAlertAndGetItsText().matches("^Are you sure you want to remove this[\\s\\S]$"));
	  }
	
}
